#include "func.h"

void delete(link *head)
{
    printf("\033c"); // 清屏
    //判断通讯录是否为空
    if (head->next == NULL)
    {
        printf("通讯录为空！\n");
        return;
    }
    printf("输入要删除的联系人名字: ");
    char name[20];
    char begin[2];
    scanf("%s", name);
    link *tmp = find(head, name);

    if (tmp->next == NULL)
    {
        head->next = NULL;
        head->prev = NULL;
    }
    else
    {
        (tmp->prev)->next = tmp->next;
        (tmp->next)->prev = tmp->prev;
    }

    free(tmp);
    printf("已删除联系人：\n%s !\n",name);
    printf("按任意键返回:");
    getchar();
    getchar();
}